;(function(window){
	var ajaxObj={
		ajax:function(obj){
			var xhr;
			try{
				xhr=new XMLHttpRequest();
			}catch(e){
				try{
					xhr=new ActiveXObject("Microsoft.XMLHTTP");
				}catch(error){
					xhr=new ActiveXObject("Msxml2.XMLHTTP");
				}
			}
			console.log('open前', xhr.readyState);
			
			if(obj.asyn==undefined){
				asyn=true;
			}else{
				asyn=obj.asyn;
			}
			xhr.open(obj.type,obj.url,asyn);
			console.log('open后', xhr.readyState);
			xhr.setRequestHeader('If-Modified-Since',0);
			if(obj.type=='post'){
				xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			}
			if(typeof(obj.data)=='object'){
				var data='';
				for(var i in obj.data){
					data+='&'+i+'='+obj.data[i];
				}
			}else{
				data=null;
			}
			xhr.send(data);
			console.log('send后', xhr.readyState);
			xhr.onreadystatechange=function(){
				if(this.readyState==4 && this.status==200){
					var response;
					switch(obj.dataType){
						case 'xml':
							response=this.responseXML;
						break;
						case 'json':
							response=JSON.parse(this.responseText);
						break;
						default:
							response=this.responseText;
						break;
					}
					obj.success(response);
				}
			}
		}
	}
	window.ajax=ajaxObj.ajax;
})(window);